<?php
class UserDB {
	var $user,
		$passwd,
		$email,
		$registrationDate;
		
	function addUser($user, $fName, $lName, $passwd, $email) {
		$registrationDate = time();
		$query = "INSERT INTO userDB VALUES('','$user','$fName','$lName','$passwd','$email','$registrationDate')";
		$result = mysql_query($query) or die('Error: ' . mysql_error());
	}
	function login($user, $passwd) {
		$rc = false;
		$query = "SELECT count(*) FROM userDB WHERE user='$user' AND passwd='$passwd'";
		$result = mysql_query($query) or die('Error: ' . mysql_error());
		$row = mysql_fetch_row($result);
		if ($row[0])
			$rc = true;
		return $rc;
	}
	
	function getUserInfo($user) {
		$query = "SELECT * FROM userDB WHERE user LIKE '%$user%'";
		$result = mysql_query($query) or die('Error: ' . mysql_error());
		$row = mysql_fetch_row($result);
		return $row;
	}
	
	function loginForm() {
		?><center>
	<form id="loginForm" method="post" action="index.php">
	<table class="loginForm">
		<tr>
			<td>User:</td>
			<td><input type="text" name="txtUser" id="txtUser" size="20" tabindex="1" /></td>
		</tr>
		<tr>
			<td>Passwd:</td>
			<td><input type="password" name="txtPasswd" tabindex="2" size="20" /></td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input type="submit" name="btn_Submit" tabindex="3" value="login" class="Button" />
				<input type="button" name="btn_Cancel" tabindex="4" value="cancel" class="Button" />
			</td>
		</tr>
	</table>
	</form>
	</center>
	<?php
	}
}
?>